<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>表单提交示例 - 基本表单提交</title>
  </head>
  <style>
    .main {
      width: 500px;
      color: #606266;
    }
    .btn {
      display: flex;
      margin-top: 20px;
      justify-content: center;
    }
    /* .el-button--primary {
      color: #fff;
      background-color: #409eff;
      border-color: #409eff;
    } */
    .el-button {
      color: #fff;
      background-color: #409eff;
      border-color: #409eff;
      display: inline-block;
      line-height: 1;
      white-space: nowrap;
      cursor: pointer;
      background: #409eff;
      border: 1px solid #dcdfe6;
      color: #fff;
      -webkit-appearance: none;
      text-align: center;
      box-sizing: border-box;
      outline: none;
      margin: 0;
      transition: 0.1s;
      font-weight: 500;
      padding: 10px 20px;
      font-size: 14px;
      border-radius: 4px;
    }
    .el-button:hover {
      background: #067df3;
      /* font-size: 30px; */
      /* border-color: #409eff; */
    }
  </style>
  <body>
    <div class="main">
      <div>
        非机载视频类型：
        <label><input name="set" type="radio" value="1" />地导视频 </label>
        <label><input name="set" type="radio" value="2" />雷达视频 </label>
        <label><input name="set" type="radio" value="3" />电抗视频 </label>
        <label><input name="set" type="radio" value="4" />打靶视频 </label>

        <!-- <select id="sel-opt">
          <option value="1">地导视频</option>
          <option value="2">雷达视频</option>
          <option value="3">电抗视频</option>
          <option value="4">打靶视频</option>
        </select> -->
      </div>
      <div class="btn">
        <button class="el-button el-button--primary" onclick="beforeSubmit()">
          提交
        </button>
      </div>
    </div>

    <script type="text/javascript">
      function beforeSubmit() {
        var sex = document.getElementsByName("set");
        let val = -1;
        for (var i = 0; i < sex.length; i++) {
          if (sex[i].checked == true) {
            val = sex[i].value;
            // console.log(val);
            break;
          }
        }

        // var oOpt = document.getElementById("sel-opt").value;
        console.log(val);
        // var username = document.getElementById("username").value;
        // var password = document.getElementById("password").value;
      }
    </script>
    <script>
      var p = new Promise((resolve, reject) => {
        setTimeout(function () {
          var count = 0;

          if (count) {
            resolve(count);
          } else {
            reject(count);
          }
        }, 1000);
      });

      p.then(
        (res) => {
          //异步调用
          console.log(res);
        },
        (err) => {
          console.log(err);
        }
      );
      // console.log(Promise.resolve("4444"));
      let a = Promise.resolve("4444");
      console.log(
        a.then((res) => {
          console.log(res);
        })
      );

      console.log(1); //比then先执行，也就证明then是异步调用
    </script>
  </body>
</html>
